import React from "react";
import { Card, Button, Empty } from "antd";
import "assets/less/components/chartWrap.less";

const ChartsWrap = ({
  children,
  data,
  title = "数据展示",
  text = "",
  handleClick = () => {}
}) => {
  let hasData = true;
  if (data && data.length <= 0) {
    hasData = false;
  }
  return (hasData ? (
    <Card
      className="chart-wrap"
      title={
        <div className="chart-wrap-title">
          <span className="dot"></span>
          {title}
        </div>
      }
      extra={
        <Button type="link" onClick={handleClick}>
          {text}
        </Button>
      }
      style={{ width: "100%", height: "100%" }}
    >
      {children}
    </Card>
  ) : <Empty />)
};

export default ChartsWrap;
